using System;
using System.Runtime.Serialization;
using System.Runtime.Remoting;

namespace Dimok.Data {
	[Serializable]
	public class RemotingException:System.Runtime.Remoting.RemotingException,ISerializable{
		private string message = "";

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Constructor. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="sectionPath">	Full pathname of the section file. </param>
		/// <param name="valueName">		Name of the value. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public RemotingException(string sectionPath,string valueName):
			this("\nValue '"+sectionPath+"/"+valueName+"' has not been found in *.config files.\n"){
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Constructor. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="message">	The message. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public RemotingException(string message){
			this.message = message;
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Default constructor. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public RemotingException(){}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Constructor. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="info">			The information. </param>
		/// <param name="context">	The context. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public RemotingException(SerializationInfo info, StreamingContext context){
			message = (string)info.GetValue("message", typeof(string));
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	
		/// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with the data
		/// needed to serialize the target object. 
		/// </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="info">			The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> to
		/// 												populate with data. </param>
		/// <param name="context">	The destination (see <see cref="T:
		/// 												System.Runtime.Serialization.StreamingContext" />) for this
		/// 												serialization. </param>
		///
		/// ### <exception cref="T:System.Security.SecurityException">	The caller does not have the
		/// 																														required permission. </exception>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public override void GetObjectData(SerializationInfo info, StreamingContext context){
			info.AddValue("message", message);
		}

		// Returns the exception information. 

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets a message that describes the current exception. </summary>
		///
		/// <value>	The message. </value>
		///
		/// ### <returns>	
		/// The error message that explains the reason for the exception, or an empty string(""). 
		/// </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public override string Message{get {return message;}}
	}
}
